<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:wh="http://java.sun.com/jsf/composite/wh"
	xmlns:p="http://primefaces.org/ui">
<h:body>
	<ui:composition template="template/template.xhtml">
		<ui:define name="content">
				<h:form id="form" styleClass="horizontal_full">
					<p:panel>
							<h1>Product Management</h1>
							<p>
								Allows you to configure, add and delete different products that should be usable in the game.
							</p>
							<p:dataTable id="productTable" var="product"
							 value="#{adminMBean.allProducts()}" rowKey="#{productTable.name}"
							 paginatorTemplate="{RowsPerPageDropdown} {CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
	                 		 rowsPerPageTemplate="10,25,50,100" paginator="true" rows="100">
							    <f:facet name="header">
						            Product Overview
						        </f:facet>
							    
							    <p:column headerText="Name" sortBy="#{product.name}">
							        <h:outputText value="#{product.name}" />
							    </p:column>
							    
							    <p:column headerText="Supplier" sortBy="#{product.supplier.supplierName}">
							        <h:outputText value="#{product.supplier.supplierName}" />
							    </p:column>
							 
							    <p:column headerText="Quality" sortBy="#{product.qualityFactor}">
							        <h:outputText value="#{product.qualityFactor}" />
							    </p:column>
							    
							    <p:column headerText="Costs" sortBy="#{product.productCosts}">
							        <h:outputText value="#{product.productCosts}" />
							    </p:column>
							    
							    <p:column headerText="Active" sortBy="#{product.active}}">
							        <p:outputPanel layout="inline" styleClass="ui-icon ui-icon-circle-check" rendered="#{product.active}" />
									<p:outputPanel layout="inline" styleClass="ui-icon ui-icon-circle-close" rendered="#{!product.active}" />
							    </p:column>
							    
							    <p:column headerText="Configure Product">
									<p:commandButton icon="ui-icon-gear" title="Configure" update="productTable"
										action="#{adminMBean.actionGoToUpdateProduct()}">
										<f:setPropertyActionListener value="#{product}"
											target="#{adminMBean.selectedProduct}" />
									</p:commandButton>
								</p:column>
						        
						        <!-- 
						        <p:column headerText="Delete Product">
									<p:commandButton icon="ui-icon-circle-minus" title="Delete"
										action="#{adminMBean.actionDeleteProduct()}"
										update="productTable">
										<f:setPropertyActionListener value="#{product}"
											target="#{adminMBean.selectedProduct}" />
									</p:commandButton>
								</p:column>
						         -->
						        		    
							    <f:facet name="footer">
							    	<p:commandButton value="Reload" action="#{adminMBean.actionRefreshAllProducts()}" update="productTable" icon="ui-icon-refresh"/>
									<p:commandButton value="Create New Product"
										action="#{adminMBean.actionGoToCreateProduct()}"
										update="productTable" icon="ui-icon-circle-plus"/>
						        </f:facet>
							</p:dataTable>
							
							<br></br>
							
							<br></br>
							<!--  
							<h3 style="margin-top: 0">User zu Spiel hinzufügen</h3>
							<p:pickList showSourceFilter="true" showTargetFilter="true" filterMatchMode="contains" 
							id="pickList" value="#{adminMBean.usersPickList}" var="user" itemLabel="#{user.nickname}" itemValue="#{user}" />
							-->
							
						</p:panel>
			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>